/*
 * Copyright 2000 - 2009 Ivan Khalopik. All Rights Reserved.
 */

package itdep.services;

import ga.domain.repository.EntityCriteria;
import ga.domain.repository.GenericEntityFilterProcessor;
import itdep.domain.CodedEntity;
import org.springframework.util.StringUtils;

/**
 * @author Ivan Khalopik
 * @version $Revision: 17 $ $Date: 2010-06-16 16:55:55 +0000 (Wed, 16 Jun 2010) $
 */
public class CodedEntityFilterProcessor extends GenericEntityFilterProcessor<CodedEntity, CodedEntityFilter<CodedEntity>> {

	public CodedEntityFilterProcessor() {
		super(CodedEntity.class);
	}

	@Override
	protected void processFilter(EntityCriteria criteria, CodedEntityFilter<CodedEntity> filter) {
		if (StringUtils.hasText(filter.getCode())) {
			criteria.add(criteria.getProperty(CodedEntity.CODE_PROPERTY).eq(filter.getCode()));
		}
	}
}
